<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            position: absolute;
            width: 40px;
            height: 40px;
        }
    </style>
</head>
<body>
    <img src="https://tse1-mm.cn.bing.net/th/id/OIP-C.jOXHUDjvrlCP26tpBD2XlwAAAA?pid=ImgDet&rs=1" alt="">
    <script>
        var pic = document.querySelector('img')
        document.addEventListener('mousemove',function(e){
            var x = e.pageX;
            var y = e.pageY;
            // console.log('x坐标是'+x,'y坐标是'+y);
            pic.style.left=x - 20 + 'px';
            pic.style.top=y - 20 + 'px';
        })
    </script>
</body>
</html>